Skip to content

Fix mastercard regex anchoring#2799

Open
SarthakDudhe wants to merge 5 commits into
validatorjs:masterfrom
SarthakDudhe:fix-mastercard-regex-anchoring
Open

Fix mastercard regex anchoring#2799
SarthakDudhe wants to merge 5 commits into
validatorjs:masterfrom
SarthakDudhe:fix-mastercard-regex-anchoring

Conversation

@SarthakDudhe

Copy link
Copy Markdown

The fix for Issue #2717 is complete and verified!
Grouped and anchored the Mastercard regex correctly in
isCreditCard.js
to avoid unanchored matches on partial strings.
Corrected the digit length validation for the Mastercard 51-55 BIN range from 4 digits (which allowed short Luhn-valid numbers like "5108") to exactly 16 digits.
Added invalid test cases (like "5108", unanchored strings, and incorrect lengths) to
validators.test.js
and verified that all 318 tests pass successfully.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a38f15b) to head (f5bf121).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2799   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2587      2587           
  Branches       656       656           
=========================================
  Hits          2587      2587           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant